package main.lph;

import java.util.Map;

import massageBox.Sender;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.widget.TabHost;
import android.widget.TextView;
import android.widget.ToggleButton;
import android.widget.TabHost.TabSpec;
import android.app.TabActivity;


public class StartActivity extends TabActivity {
	
	Map<String, Object> changeMap = null;
	Sender sender = new Sender();
	
	
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	
	    Log.i("info","StartActivity.onCreate was lunch");
	    
	    // TODO Auto-generated method stub
	    setContentView(R.layout.activity_living);
	    
	    
	    TabHost tabHost = getTabHost();
	    
        // Create Tabs for Light and Window
        TabSpec lightspec = tabHost.newTabSpec("Licht");
        TabSpec windowspec = tabHost.newTabSpec("Licht");

        
        
        Intent myLightIntent = new Intent(this,LightActivity.class);
        Intent myWindowIntent = new Intent(this,WindowActivity.class);
        
        // setting Title for tabs      
        lightspec.setIndicator("Licht").setContent(myLightIntent);
        windowspec.setIndicator("Fenster").setContent(myWindowIntent);
        
        // add tabs
        tabHost.addTab(lightspec); 
        tabHost.addTab(windowspec); 
        
        myLightIntent.setType("livingRoom");
        myWindowIntent.setType("livingRoom");
    
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
			
		// Inflate the menu; this adds items to the action bar if it is present.
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.activity_start, menu);
		return true;
	}
	
	
	
	
	

//	@Override
//	protected void onCreate(Bundle savedInstanceState) {
//		super.onCreate(savedInstanceState);
//		
//	    // TODO Auto-generated method stub
//	    //setContentView(R.layout.activity_living);
//
//		setContentView(R.layout.activity_start);
//	}
	

	
//	
//	//itoggleButton for sleeping room - switch light on | light off
//	public void itoggleButtonSleeping(View v){
//		
//		Log.i("info","StartActivity.itoggleButtonSleeping was lunch");
//	
//		ToggleButton tb = (ToggleButton) findViewById(R.id.toggleButtonSleeping);
//		if (tb.isChecked()){
//			//send message for switch on light for sleeping room
//			changeMap = sender.sendLight("SLEEPING", true);
//			setText("SLEEPING","on");
//		}
//		else{
//			//send message for switch off light for sleeping room
//			changeMap = sender.sendLight("SLEEPING", false);
//			setText("SLEEPING","off");
//		}
//	}
//	
//	
//	//itoggleButton for living room - switch light on | light off
//	public void itoggleButtonLiving(View v){
//	
//		ToggleButton tb = (ToggleButton) findViewById(R.id.toggleButtonLiving);
//		if (tb.isChecked()){
//			//send message for switch on light
//			changeMap = sender.sendLight("LIVING", true);
//			setText("LIVING","on");
//		}
//		else{
//			//send message for switch off light
//			changeMap = sender.sendLight("LIVING", false);
//			setText("LIVING","off");
//		}
//	}
//	
//	//itoggleButton for dining room - switch light on | light off
//	public void itoggleButtonDiner(View v){
//	
//		ToggleButton tb = (ToggleButton) findViewById(R.id.toggleButtonDining);
//		if (tb.isChecked()){
//			//send message for switch on light
//			changeMap = sender.sendLight("DINING", true);
//			setText("DINING","on");
//		}
//		else{
//			//send message for switch off light
//			changeMap = sender.sendLight("DINING", false);
//			setText("DINING","off");
//		}
//	}
//	
//	//itoggleButton for kitchen room - switch light on | light off
//	public void itoggleButtonKitchen(View v){
//	
//		ToggleButton tb = (ToggleButton) findViewById(R.id.toggleButtonKitchen);
//		if (tb.isChecked()){
//			//send message for switch on light
//			changeMap = sender.sendLight("KITCHEN", true);
//			setText("KITCHEN","on");
//		}
//		else{
//			//send message for switch off light
//			changeMap = sender.sendLight("KITCHEN", false);
//			setText("KITCHEN","off");
//		}
//	}
//	
//	
//
//	private void setText(String room, String status){
//		
//		String returnString = sender.send(changeMap, "LP.LIGHTCONTROL");
//		
//		TextView textView1 = (TextView) findViewById(R.id.textView_light);
//		
//		textView1.setText("Msg: "+room+ " - switch: "+status+" Send: "+returnString);
//	}
//	
//	
//	
	
	
	
	
//	public void iButtonKitchen_OnClick(View v){
//		Intent myIntent = new Intent (v.getContext(), KitchenActivity.class);
//		startActivityForResult(myIntent,0);
//
//	}
//	
//	public void iButtonLiving_OnClick(View v){
//		Intent myIntent = new Intent (v.getContext(), LivingActivity.class);
//		startActivityForResult(myIntent,0);
//	}
//	
//	public void iButtonSleeping_OnClick(View v){
//		TextView textView1 = (TextView) findViewById(R.id.textView1);
//		textView1.setText("Sleepingroom!!!");
//	}
//	
//	public void iButtonDining_OnClick(View v){
//		TextView textView1 = (TextView) findViewById(R.id.textView1);
//		textView1.setText("Diningroom!!!");
//	}
	
	



}
